<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../../../layuiadmin/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="../../../../layuiadmin/style/admin.css" media="all">
		<link rel="stylesheet" href="../../../../css/common.css" media="all">

	</head>

	<body>

		<div class="layui-fluid">
			<div class="layui-row" id="view">
				<form class="layui-form" lay-filter="test_detail">
					<div class="layui-card">
						<div class="layui-card-body">
							<div class="layui-form-item">
								<label class="layui-form-label">状态</label>
								<div class="layui-input-block on_off"></div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">客户端</label>
								<div class="layui-input-block icon_client"></div>
							</div>
  							<div class="layui-form-item">
								<label class="layui-form-label">标题：</label>
								<div class="layui-input-block">
									<input type="text" name="title" class="layui-input" id="title" autocomplete="off" placeholder="标题">
								</div>  
							</div>
  							<div class="layui-form-item">
								<div class="layui-block">
									<label class="layui-form-label">会员类型</label>
									<div class="layui-input-block">
										<select  name="sub_type" class="sub_type member_sub_type"></select>
									</div>
								</div> 
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">账户类型：</label>
								<div class="layui-input-block">
									<select name="accountid" class="accountid accoun_type"></select>
								</div>
							</div>
 							<div class="layui-form-item">
								<label class="layui-form-label">值：</label>
								<div class="layui-input-block">
									<input type="text" name="value" class="layui-input" id="value" autocomplete="off" placeholder="值">
								</div>  
							</div>
							
							<div class="layui-form-item">
								<label class="layui-form-label">描述：</label>
								<div class="layui-input-block">
									<input type="text" name="description" class="layui-input" id="description" autocomplete="off" placeholder="描述">
								</div>  
							</div>
							
							<div class="layui-form-item">
								<label class="layui-form-label">时效（小时）：</label>
								<div class="layui-input-block">
									<input type="text" name="aging" class="layui-input" id="aging" autocomplete="off" placeholder="时效（小时）">
								</div>  
							</div>
							
							<div class="layui-form-item">
								<label class="layui-form-label">手续费：</label>
								<div class="layui-input-block">
									<input type="text" name="fee" class="layui-input" id="fee" autocomplete="off" placeholder="手续费">
								</div>  
							</div>
							<!--<div class="layui-form-item">
								<label class="layui-form-label">手续费：</label> 
								<div class="layui-input-block">
									<input type="text" name="charge" class="layui-input" id="charge" autocomplete="off" placeholder="手续费">
								</div>  
							</div>-->
							<div class="layui-form-item">
								<label class="layui-form-label">最高提现金额：</label>
								<div class="layui-input-block">
									<input type="text" name="quota" class="layui-input" id="quota" autocomplete="off" placeholder="最高提现金额">
								</div>  
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">最低提现金额：</label>
								<div class="layui-input-block">
									<input type="text" name="low" class="layui-input" id="low" autocomplete="off" placeholder="最低提现金额">
								</div>  
							</div>

						</div>
					</div>
					<div class="layui-form-item layui-layout-admin">
						<div class="layui-input-block">
							<div class="layui-footer" style="left: 0;">
								<button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
							</div>
						</div>
					</div>
				</form>
			</div>
		</div>
		<script src="../../../../layuiadmin/layui/layui.js"></script>
		<script src="../../../../js/jquery.min.js"></script>
		<script src="../../../../js/jquery.jqprint-0.3.js"></script>
		<script src="../../../../js/common.js"></script>
		<script>
			var _data = {
				id: getParam('id'),
				type: ''
			}
			var _member = {
				
			}
			layui.config({
				base: '../../../../layuiadmin/' //静态资源所在路径
			}).extend({
				index: 'lib/index' //主入口模块
			}).use(['index', 'form', 'laytpl', 'laydate', 'layedit', 'upload', 'colorpicker'], function() {
				var $ = layui.$,
					admin = layui.admin,
					upload = layui.upload,
					laytpl = layui.laytpl,
					laydate = layui.laydate,
					layedit = layui.layedit,
					colorpicker = layui.colorpicker;
				form = layui.form; 
				
				if(_data.id) {
					initdata();
				}
				on_off_show('radio')
				icon_client_show('checkbox')
				accoun_type_show("option")
				member_sub_type_show('option')
				var img_arr1 = [],
					img_arr2 = [];
				form.on('checkbox(type)', function(data) {
					// console.log(data.value);
				});
				//监听提交
				form.on('submit(demo1)', function(data) {
					var data = data.field;
					_data = Object.assign(_data, data); 
					for (item in data){ 
						if(/^t/.test(item)){
							if(item.substr(0,4) == 'type'){
								_data.type += data[item]+',' 
							} 
						} 
					} 
					_data.type = (_data.type.substring(_data.type.length-1) == ',') ? _data.type.substring(0,_data.type.length-1) : _data.type;
					layer.confirm('确定要提交数据？', function() {
						loading();
						if(_data.id) {
							submitdata(server.settlement_edit);
						} else {
							delete _data.id
							submitdata(server.settlement_insert);
						}
					}, function() {
						layer.msg('取消操作');
					});
					return false;
				});

				function submitdata(_url) {
					$.post(_url, _data, function(res, status) {
						if(status == 'success') {
							if(res.code == 0) {
								layer.alert('操作成功', function() {
									parent.layer.closeAll();
									parent.layui.table.reload('test-table-operate');
								});
							} else {
								layer.msg(res.msg);
							}
							closeloading();
						} else {
							closeloading();
							layer.msg('服务器连接错误');
						}
					});
				}

				function initdata() {
					$.get(server.settlement_detail, _data, function(res, status) {
						if(status == 'success') {
							if(res.code == 0) {
								var data = res.settlement  
								if(data.data.type){
									var type_arr = data.data.type.split(',')
									for (var i = 0; i < type_arr.length; i++) {
										$(".icon_type input[value=" + type_arr[i] + "]").attr("checked", true)
									}
								}
								form.val("test_detail", data.data);
								form.render();
							} else {
								layer.msg(res.msg);
							}
						} else {
							layer.msg('服务器连接错误');
						}
					});
				} 
				
				 
			});
		</script>
	</body>

</html>